set more off

/* This file replicates the results in Table 1, Chegere, Eggert & Söderbom (CES) */ 


/*cd "C:\xxx....*/


use "CES2019_data.dta" , clear

keep if wave==1 & est_sample==1


mat store=J(35,15,0)

local k=0

foreach yvar in sex age schooling activeworkers hhsize income wealth maizeexperienceyears trained agriclandarea maizelandarea maizeplots ///
amountharvested amountstored soldmaize amountsold amountsoldin3months propsoldin3months averageprice weatheratharvest harvestmatured ///
immediatestorage maizesorted dryingperiod storedisinfected usedprotectants Spraying Trappoison protcostperton prestolossprop stolossprop ///
selllossprop phl {

local k=`k'+1

sum `yvar'
mat store[`k',1]=r(N)
mat store[`k',2]=r(mean)
mat store[`k',3]=r(sd)
sum `yvar' if bagstreatment==0 & traintreatment==0
mat store[`k',4]=r(mean)
mat store[`k',5]=r(sd)
sum `yvar' if bagstreatment==0 & traintreatment==1
mat store[`k',6]=r(mean)
mat store[`k',7]=r(sd)
sum `yvar' if bagstreatment==1 & traintreatment==0
mat store[`k',8]=r(mean)
mat store[`k',9]=r(sd)

reg `yvar' traintreatment if bagstreatment==0, cluster (villagecode)
mat store[`k',10]=-_b[traintreatment]
boottest traintreatment, cluster (villagecode) nograph noci
mat store[`k',11]=r(p)

reg `yvar' bagstreatment if traintreatment==0, cluster (villagecode)
mat store[`k',12]=-_b[bagstreatment]
boottest bagstreatment, cluster (villagecode) nograph noci
mat store[`k',13]=r(p) 

reg `yvar' bagstreatment if traintreatment==1 | bagstreatment==1, cluster (villagecode)
mat store[`k',14]=-_b[bagstreatment]
boottest bagstreatment, cluster (villagecode) nograph noci
mat store[`k',15]=r(p)
}

mat store=store[1..`k',.]
mat list store


exit


